package com.mall.shopping.services;

import com.mall.shopping.IContentService;
import com.mall.shopping.converter.ContentConverter;
import com.mall.shopping.converter.ProductCateConverter;
import com.mall.shopping.dal.entitys.ItemCat;
import com.mall.shopping.dal.entitys.PanelContent;
import com.mall.shopping.dal.persistence.ItemCatMapper;
import com.mall.shopping.dal.persistence.PanelContentMapper;
import com.mall.shopping.dto.NavListResponse;
import com.mall.shopping.dto.PanelContentDto;
import com.mall.shopping.dto.ProductCateDto;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class IContentServiceImpl implements IContentService {

    @Autowired
    ItemCatMapper mapper;

    @Autowired
    ContentConverter converter;

    @Override
    public NavListResponse queryNavList() {
        Example example = new Example(ItemCat.class);
        example.createCriteria().andEqualTo("isParent", "1").andEqualTo("status", 1);

        List<ItemCat> itemCats = mapper.selectByExample(example);
        List<PanelContentDto> panelContentDtos = converter.panelListCat2Dto(itemCats);
        NavListResponse response = new NavListResponse();
        response.setPannelContentDtos(panelContentDtos);
        return response;
    }
}
